﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuanLyBanHang.VO;


namespace QuanLyBanHang
{
    public partial class Form_main : Form
    {
        NhanVien_VO nv = new NhanVien_VO();
        //Form_HD hd;
        //Form_Help help = new Form_Help();
        //Form_KH kh = new Form_KH();
        Form_LogIn login;
        //Form_NhapXuat nx = new Form_NhapXuat();
        //Form_NV frm_nv = new Form_NV();
        //Form_PN pn;
        //Form_SP sp = new Form_SP();
        Form[] frm = new Form[7];
        public Form_main(NhanVien_VO nvien,Form_LogIn log)
        {
            InitializeComponent();
            nv = nvien;
            //hd = new Form_HD(nv);
            //pn = new Form_PN(nv);
            login = log;
            frm[0] = new Form_Help();
            frm[1] = new Form_KH();
            frm[2] = new  Form_NhapXuat();
            frm[3] = new Form_NV2();
            frm[4] = new Form_SP1();
            frm[5] = new Form_HD(nv);
            frm[6] = new Form_PN(nv);
            //frm_nv.MdiParent = this;
            //hd.MdiParent = this;
            //pn.MdiParent = this;
            //kh.MdiParent = this;
            //sp.MdiParent = this;
            //help.MdiParent = this;
            //nx.MdiParent = this;
            //MdiClient mc;
            //foreach (Control c in this.Controls)
            //{
            //    if (c is MdiClient)
            //        c.BackColor = this.BackColor;
            //}
        }

        private void button1_Click(object sender, EventArgs e)
        {
            frm[1] = new Form_KH();
            frm[1].Show();
        }

        private void Form_main_Load(object sender, EventArgs e)
        {
            label_ten.Text += nv.hoten;
            if (nv.quyen == 1)
            {
                label_chuc.Text += "Quản lý";
                button_bc.Enabled = true;
                button_ql.Enabled = true;
            }
            else label_chuc.Text += "Nhân viên";
        }

        private void button2_Click(object sender, EventArgs e)
        {
            frm[4] = new Form_SP1();
            frm[4].Show();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            frm[5] = new Form_HD(nv);
            frm[5].Show();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            frm[6] = new Form_PN(nv);
            frm[6].Show();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            frm[3] = new Form_NV2();
            frm[3].Show();
        }

        private void button6_Click(object sender, EventArgs e)
        {
           frm[2] = new Form_NhapXuat();
            frm[2].Show();
        }

        private void button7_Click(object sender, EventArgs e)
        {
            frm[0] = new Form_Help();
            frm[0].Show();
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            //for (int i = 0; i < Application.OpenForms.Count; i++) Application.OpenForms[i].Close();
            //Application.Restart();                        
            //Form_LogIn frm = new Form_LogIn();
            //frm.Show();
            foreach (Form f in frm)
            {
                f.Close();
            }
            this.Close();
            login.Show();

        }

        private void Form_main_FormClosing(object sender, FormClosingEventArgs e)
        {
            //Application.Exit();
            //this.Hide();
            
            //foreach (Form f in frm)
            //{
            //    f.Close();
            //}
            //this.Close();
            //login.Show();
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}
